package com.example.haiyang.controller;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.example.haiyang.domain.User;
import com.example.haiyang.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * 用户表，所有的用户信息在这里存着 前端控制器
 * </p>
 *
 * @author haiyang
 * @since 2019-11-23
 */
@Controller
@RequestMapping("/haiyang/user")
public class UserController {

    @Autowired
    IUserService iUserService;

    /**
     * 判断用户名是否重复
     * @param name
     * @return
     */
    @RequestMapping("/isName")
    @ResponseBody
    public Map isName(String name){
        User user = iUserService.selectOne(new EntityWrapper<User>().eq("name", name));
        Map map = new HashMap<>();
        if (user!=null){
            map.put("success","false");
            map.put("data","用户名重复");
            return map;
        }
        map.put("success","false");
        map.put("data","用户名重复");
        return map;
    }

}

